home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: initializeTrans.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:02 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "latch.h"
- #include "bf.h"
- #include "volume.h"
- #include "trans.h"
- #include "util_funcs.h"
- #include "trans_intfuncs.h"
- #include "trans_extfuncs.h"
- #include "bf_globals.h"
- #include "trans_globals.h"
-
-
- void
- initializeTrans ()
-
- {
-
- TRANSVOLREC *transVolRec;
- TRANSREC *transRec;
- int spaceNeeded;
- int i;
-
- TRACE(TR_TRANS, TR_LEVEL_1);
-
- /*
- * Initialize the transaction pool and active list
- */
- initializePool( &TransRecPool, (ALLOCFUNC) allocTransRec, NumTransRecs );
- initializeList( &ActiveTransList );
-
- /*
- * calculate how much space to allocate for transaction records
- */
- spaceNeeded = sizeof(TRANSREC) * NumTransRecs;
-
- /*
- * Attempt to allocate the space
- */
- if ((TransRecPtr = transRec = (TRANSREC *) malloc(spaceNeeded)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmMALLOCFAILED);
- }
-
- /*
- * initialize the individual transaction records
- */
- for (i = 0; i < NumTransRecs; i++, transRec++) {
-
- /*
- * Initialize the transaction record.
- */
- initTransRec(transRec);
-
- /*
- * put the record in the pool
- */
- listEnq( &(TransRecPool.freeList), &(transRec->tidList) );
-
- }
-
- /*
- * get the size of the transaction hash table
- * and setup the hash mask
- */
- TransTableSize = findLog2(NumTransRecs);
- TransHashMask = TransTableSize - 1;
- TRPRINT(TR_TRANS, TR_LEVEL_2, ("TransTableSize:%d TransHashMask:%d",
- TransTableSize, TransHashMask));
- TransTableSize = RAISETWO(TransTableSize);
-
- /*
- * get the space needed for the transaction table
- */
- spaceNeeded = TransTableSize * sizeof(LIST);
-
- /*
- * Attempt to allocate the space
- */
- if ((TransHashTable = (LIST *) malloc(spaceNeeded)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmMALLOCFAILED);
- }
-
- /*
- * initialize the individual transaction records
- */
- for (i = 0; i < TransTableSize; i++) {
-
- /*
- * initialize the list components
- */
- initializeList( &(TransHashTable[i]) );
- }
-
- /*
- * initialize the transvol pool
- */
- initializePool( &TransVolRecPool, NULL, NumTransVolRecs );
-
- /*
- * get the space needed for the transaction table
- */
- spaceNeeded = NumTransVolRecs * sizeof(TRANSVOLREC);
-
- /*
- * Attempt to allocate the space
- */
- if ((transVolRec = (TRANSVOLREC *) malloc(spaceNeeded)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmMALLOCFAILED);
- }
-
- /*
- * initialize the individual transaction records
- */
- for (i = 0; i < NumTransVolRecs; i++, transVolRec++) {
-
- initializeListElement( &(transVolRec->volumeList), (char *) transVolRec );
- initializeListElement( &(transVolRec->transList), (char *) transVolRec );
- INIT_TRANSVOLREC_MAGIC(transVolRec);
-
- listEnq( &(TransVolRecPool.freeList), &(transVolRec->volumeList) );
- }
-
- /*
- * initialize the transaction info structure
- */
- TransInfo.transState = T_ACTIVE;
- TransInfo.logState = L_OFFLINE;
- TransInfo.tidSequence = 1; /* MJZ: added -- Tid 0 is special */
-
- /*
- * Init the shutdown wait list
- */
- initializeList( &TransShutdownWaitList );
-
- /*
- * calculate how much space to allocate for the dirty pages table
- */
- DirtyPageTableMaxSize = NumBuffers;
- spaceNeeded = sizeof(DIRTYPAGEINFO) * DirtyPageTableMaxSize;
-
- /*
- * Attempt to allocate the space
- */
- if ((DirtyPageTable = (DIRTYPAGEINFO *) malloc(spaceNeeded)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmMALLOCFAILED);
- }
-
- /*
- * calculate how much space to allocate holding are for log
- * information listing dirty pages. Initialize the semaphore
- * for this table.
- */
- spaceNeeded = sizeof(DIRTYPAGELOGINFO) * DirtyPageTableMaxSize;
- initializeSemaphore(&DirtyPageLogInfoSemaphore, FALSE);
-
- /*
- * Attempt to allocate the space
- */
- if ((DirtyPageLogInfo = (DIRTYPAGELOGINFO *) malloc(spaceNeeded)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmMALLOCFAILED);
- }
-
- initializeRecoveryDirtyPageTable();
- }
-